<template>
    <div>
         <LoginHeader>
        <i class="el-icon-arrow-left" slot="i" @click="goback"></i>
        <span slot="title">修改密码</span>
        <span slot="more"></span>
        </LoginHeader>
         <div class="edit">
            <i class="el-icon-lock"></i>
            <input type="text" placeholder="输入原密码" v-model="pas" >
        </div>
        <div class="btn">
            <el-button type="primary" :disabled="next" @click="pastrue">下一步</el-button>
        </div>
    </div>
</template>
<script>
import LoginHeader from '@/components/njrcomponents/login_header.vue'
export default {
    data(){
        return{
            next:true,
            pas:''
        }
    },
    watch:{
        pas:function(){
            if(this.pas.trim()!==''){
                this.next=false
            }else{
                this.next=true
            }
        }
    },
 components:{
        LoginHeader
    },
    methods:{
        goback(){
            this.$router.go(-1)
        },
        pastrue(){
            this.$http.get('/api/users/'+this.$store.state.username)
            .then(({
                data,config
            })=>{
                if(data.code==200){
                    console.log(data.data.password);
                    if(this.pas==data.data.password){
                        this.$router.push({name:'Editnewpass',params:{password:data.data.password}})
                    }else{
                    this.$message.error('密码输入错误')
                    }
                }else{
                    this.$message.error('查询密码失败')
                }
            })
        }
    }
}
</script>
<style lang="less" scoped>
.edit{
    // background-color: #f7f7f8;
    border-top: 1px solid #f8f8f8;
    border-bottom: 1px solid #f8f8f8;
    margin: 100px 0 20px;
    padding: 20px 0;
    i{
        margin: 15px 50px;
    }
    input{
        border: none;
        outline: none;
    }
}
.btn{
    text-align: center;
    margin-top: 50px;
    .el-button{
    width: 50%;
    border-radius: 40px;
    padding: 15px;
}
}

</style>